package xiaozhi.modules.chat.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xiaozhi.common.utils.Result;
import xiaozhi.common.validator.ValidatorUtils;
import xiaozhi.modules.chat.dto.ChatDTO;
import xiaozhi.modules.chat.dto.MemDTO;
import xiaozhi.modules.chat.service.ChatService;

/**
 * 类
 *
 * @author wanglunhui
 * @since 2025-04-25 09:48:34
 */
@Tag(name = "聊天管理")
@AllArgsConstructor
@RestController
@RequestMapping("/chat")
public class ChatController{

    private final ChatService chatService;

    @PostMapping("/chat")
    @Operation(summary = "聊天")
    public Result<String> chat(@RequestBody ChatDTO chatDTO){
        ValidatorUtils.validateEntity(chatDTO);
        return new Result<String>().ok(chatService.chat(chatDTO));
    }

    @PostMapping("/memory")
    @Operation(summary = "记忆入库")
    public Result<String> saveMemory(@RequestBody MemDTO memDTO){
        ValidatorUtils.validateEntity(memDTO);
        return new Result<String>().ok(chatService.SaveMem(memDTO));
    }
}
